﻿using System;
using Test30.Core;

namespace Test30.Engine
{
    public class FluidStat:StatBase
    {
        public int Min => 0;
        public int Max => Base + BonusTotal;

        public int Current
        {
            get => _current;
            set
            {
                value = value.Clamp(Min, Max);
                if (_current != value)
                {
                    _current = value;
                    OnChanged();
                }
            }
        }
        public bool IsMax => Current == Max;
        public FluidStat(int baseValue) : base(baseValue)
        {
            _current = Base;
        }

        protected override int GetBaseMin()
        {
            return Min;
        }

        protected override int GetBaseMax()
        {
            return Int32.MaxValue;
        }
        protected override void OnBaseChanged()
        {
            KeepCurrentInBounds();
        }
        protected override void OnBonusChanged()
        {
            base.OnBonusChanged();

            KeepCurrentInBounds();
        }
        private void KeepCurrentInBounds()
        {
            _current = _current.Clamp(Min, Max);
        }
        private int _current;
    }
}
